Onwards: the assembler path
Every single Amiga coder I talked to says the same thing: trying to write a game or a demo in system friendly C that runs on a standard A500 is batshit crazy.
Apparently I'm making it unnecessarily complex for myself.
I really should move to assembler.
Usually when I wander into unknown territory that looks like a steep hill, I jump on, find something to hold on to and start climbing.
Assembler feels like an iceberg instead of a hill: I jump on, don't find anything I recognise to grasp and slip back down.
So: back to babysteps.
Let's start with the very beginning: pick the Photon course and go with AsmTwo
Ha! First hurldle: I'm on a Mac with an AZERTY keyboard, using FS-UAE and I can't type the # char in the amiga editor.
Failed at the first line of the coding tutorial :-)
AsmTwo (and AsmOne) seem like super tools IF you know how they work :-)
So in the light of those babysteps:
- When you start the program, you have to type a number of how much memory you want to assign (seems obvious if you know it, but I had no clue)
- use "escape" to toggle between the editor and the cli
- in the cli, use
- "a" to assemble
- "j" to jump to the first command (and execute the program)
- "wo" to write your assembled binary to disk.
First tutorial completed. Yay!
waitmouse:
btst #6,$bfe001
bne waitmouse
rts
The integrated CoPilot in modern editors explains that
- btst stands for "Bit Test", it stores the result of the test in the "Condition Code Register"
- bne stands for "Branch if not equal" it tests the Condition Code Register
- rts stands for "Return from SubRoutine"
Good to know, that actually makes sense.
Still I'm going to sprinkly the code with comments that explain exactly what is going on.
Speaking of comments:
both AsmTwo and Vasm handle source code with "//" style inline comments,
but PhxAss complaints about the syntax and only assembles it when I remove all comments.
Some Googling indicated that I should start comments with "# " or a pipe | , but that's also not to PhxAss' liking... not a scooby.
(Update: found it: it's the ";" char, works also on Vasm/AsmTwo and gives correct highlight colors in VSCode)
And another usefull snippet: vasm won't generate amiga binaries as output by default, you have to supply some command line options:vasmm68k_mot -kick1hunks -Fhunkexe -o filename source.asm
Moving forward, both AsmTwo and Vasm seem well suited.
AsmTwo might be nicer for monitoring and debugging as it's integrated.
Vasm seems a better fit for my "write code on PC, compile on Amige" approach I liked so much working on Ordo.
For Vasm, I haven't figured out yet how the build using a MakeFile.
For now, I just use a build script.
TIP: to make that executable without having to use "execute": protect build.script +se
TIP2: avoiding "magical number" like $bfe001 seems useful to keep my head straight.
$bfe001 is the hardware address for the first CIA cheip, that handles a.o. the mouse input.
you can assign variables to make that more clear like this:
ciaa = $bfe001
ciab = $bfd000
waitmouse:
btst #6,ciaa ; test bit in the first CIA
bne waitmouse ; branch if not equal
rts ; return form subroutine